﻿using NHibernate;
using NHibernate.Linq;
using Ninject;

namespace Machinery
{
    public abstract class World : IPart
    {
        protected World(IKernel kernel)
        {
            Kernel = kernel;
        }

        public IKernel Kernel { get; internal set; }

        public T Get<T>() 
        {
            return Kernel.Get<T>();
        }

        public ISession Database
        {
            get { return Kernel.Get<ISession>(); }
        }

        public INHibernateQueryable<T> DatabaseTable<T>()
        {
            return Kernel.Get<ISession>().Linq<T>();
        }
    }
}
